/*
 * @Author: szx
 * @Date: 2022-04-09 14:03:04
 * @LastEditTime: 2022-04-09 14:10:21
 * @Description: 
 * @FilePath: \leetcode\剑指offerII\047\047.js
 */
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {TreeNode}
 */
var pruneTree = function (root) {
    if (!root) return null;
    root.left = pruneTree(root.left);
    root.right = pruneTree(root.right)
    if (root.val == 0 && !root.left && !root.right) return null;
    return root;
};